#include <bits/stdc++.h>
using namespace std;

class Solution {
public:
    string reverseStr(string s, int k) {
        int n = s.size();
        int left = 0;
        while(left<n){
            int tn = k;
            if(left+k>n) tn=n-left;
            for(int i=0; i<(tn>>1); ++i){
                swap(s[left+i], s[left+tn-i-1]);
            }
            left+=(k<<1);
        }
        return s;
    }
};

int main(){
    Solution solution;
    solution.reverseStr("abcdefg", 2);
}